Skip to content

fix: display percentage values - #49

Merged
viennaa merged 3 commits into
cloudoperators:mainfrom
jeoffzheng:fix/humanize-percentage-annotations
Jul 7, 2026
Merged

viennaa merged 3 commits into
cloudoperators:mainfrom
jeoffzheng:fix/humanize-percentage-annotations

Conversation

@jeoffzheng

@jeoffzheng jeoffzheng commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Fix

correct the percentage value display in the alerts

Chart version

Bumped 1.3.0 → 1.3.1

Copilot AI review requested due to automatic review settings July 2, 2026 11:50
@jeoffzheng
jeoffzheng requested a review from a team as a code owner July 2, 2026 11:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects alert annotation rendering for PromQL expressions that already return 0–100 scale percentages, preventing inflated % values in notifications, and updates related chart/plugin metadata.

Changes:

  • Replaced humanizePercentage with humanize + literal % for affected 0–100 alert values (API availability, node CPU %, node disk usage %), and fixed the CPU alert’s dig key + missing space in the message.
  • Simplified KubeletManyRequestErrors threshold expression from * 100 > 1 to the equivalent > 0.01.
  • Bumped chart/plugin versions (but currently inconsistent with the PR description and with each other).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
charts/kubernetes-operations/plugindefinition.yaml Bumps PluginDefinition version and referenced Helm chart version.
charts/kubernetes-operations/Chart.yaml Updates the Helm chart version.
charts/kubernetes-operations/alerts/kubernetes-node.yaml Fixes CPU and disk percentage annotation formatting and corrects the dig key for CPU alert config overrides.
charts/kubernetes-operations/alerts/kubernetes-kubelet.yaml Rewrites the request error ratio threshold to an equivalent non-percent form.
charts/kubernetes-operations/alerts/kubernetes-apiserver.yaml Fixes aggregated API availability annotation formatting to avoid double-scaling percent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread charts/kubernetes-operations/Chart.yaml Resolved
KubeAggregatedAPIDown, KubernetesNodeHostHighCPUUsage, and
KubernetesNodeHighDiskUsagePercentage all produce PromQL values on a
0-100 scale. humanizePercentage expects a 0-1 ratio and multiplies by
100, causing values like 81.82 to render as 8182% in notifications.

Also fix typo: missing space before "has" in KubernetesNodeHostHighCPUUsage
description.

Bump chart version 1.3.0 -> 1.3.1
Bump plugindefinition spec.version 1.2.0 -> 1.2.1 and helmChart.version 1.3.0 -> 1.3.1

Signed-off-by: jeoffzheng <jeoff.zheng@sap.com>
@jeoffzheng
jeoffzheng force-pushed the fix/humanize-percentage-annotations branch from a787b56 to ad0e83e Compare July 2, 2026 12:01

@viennaa viennaa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting and acting on this problem. Little suggestion from my side.

jeoffzheng added a commit to jeoffzheng/kubernetes-operations that referenced this pull request Jul 6, 2026
Replace `humanize` with `printf "%.2f"` in all three alert descriptions
to ensure consistent 2-decimal-place output. humanize can produce
abbreviated values (1.1k, 1M) which is unsuitable for percentages.
Also move the literal % outside the backtick-formatted value.

Addresses review feedback from viennaa on PR cloudoperators#49.
Replace `humanize` with `printf "%.2f"` in all three alert descriptions
to ensure consistent 2-decimal-place output. humanize can produce
abbreviated values (1.1k, 1M) which is unsuitable for percentages.
Also move the literal % outside the backtick-formatted value.

Addresses review feedback from viennaa on PR cloudoperators#49.

Signed-off-by: jeoffzheng <jeoff.zheng@sap.com>
@jeoffzheng
jeoffzheng force-pushed the fix/humanize-percentage-annotations branch from 337e9c1 to f092f14 Compare July 6, 2026 09:10
@jeoffzheng

Copy link
Copy Markdown
Contributor Author

@viennaa , thanks for the comments, update the PR with the changes. please review it again. thx.

@viennaa

viennaa commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Please adjust the description and PR title to reflect the actual change. Also don't write down what function has changed to which function in the title, as this can be seen in the diff. Rather have the reasoning in it.

@jeoffzheng jeoffzheng changed the title fix: replace humanizePercentage with humanize+% for 0-100 scale values fix: replace humanizePercentage with printf "%.2f" +% for 0-100 scale values Jul 6, 2026
@jeoffzheng

Copy link
Copy Markdown
Contributor Author

Please adjust the description and PR title to reflect the actual change. Also don't write down what function has changed to which function in the title, as this can be seen in the diff. Rather have the reasoning in it.

yeah.. sorry for missing this part... now all updated.

@jeoffzheng jeoffzheng changed the title fix: replace humanizePercentage with printf "%.2f" +% for 0-100 scale values fix: correct display percentage values Jul 6, 2026
@viennaa viennaa changed the title fix: correct display percentage values fix: display percentage values Jul 6, 2026
printf "%.2f" renders literal double-quotes into the YAML value.
Unquoted YAML scalars and double-quoted strings both break when they
contain unescaped double-quotes. Switch the three affected annotations
to single-quote YAML scalars so the inner double-quotes are safe.

Signed-off-by: jeoffzheng <jeoff.zheng@sap.com>
@viennaa

viennaa commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Can you add the fix to this file too for:

https://github.com/cloudoperators/kubernetes-operations/blob/main/charts/kubernetes-operations/alerts/kubernetes-kubelet.yaml

KubeletTooManyPods
KubeletManyRequestErrors

@jeoffzheng
jeoffzheng force-pushed the fix/humanize-percentage-annotations branch from ea8b45d to e8f0913 Compare July 7, 2026 08:07
@jeoffzheng

jeoffzheng commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor Author

Can you add the fix to this file too for:

https://github.com/cloudoperators/kubernetes-operations/blob/main/charts/kubernetes-operations/alerts/kubernetes-kubelet.yaml

KubeletTooManyPods KubeletManyRequestErrors

both alerts KubeletTooManyPods & KubeletManyRequestErrors — the value is 0–1 ratio , so this one actually is a 0–1 scale and humanizePercentage would be correct...

@viennaa
viennaa merged commit de33aa1 into cloudoperators:main Jul 7, 2026
9 checks passed
@jeoffzheng
jeoffzheng deleted the fix/humanize-percentage-annotations branch August 6, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants